<?php
namespace app\serverfund\service\currency;

use \app\manage\service\ApiBase;
/**
 * @author:      李颖
 * @DateTime:    2017-07-14 10:31:21
 * @Description: 亚艺后台的数字币账户 调用newthink项目下的接口
 */
class CurrencyAccount extends ApiBase
{
    protected $currencyAccountValidate = '\app\serverfund\validate\CurrencyAccount';
    protected $currencyAccountLogic = '\app\serverfund\logic\CurrencyAccount';

    /*兑换钱*/
    public function exchange(): array 
    {
        $data = $this->haveIssetReceiveData(['exchange'=>' ', 'money'=>0, 'currency_scale'=>0, 'token'=>' ']);
        return $this->stepRun($data, 'serverfund/currency/CurrencyAccount/exchange', 'exchange', 'exchange');
    }
    # 充值 系统->a
    public function prepaid(): array
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'currency'=>'0', 'token'=>' ', 'user_info'=>'{}', 'opposite_info'=>'{}', 'remark'=>'']);
        $data['update_ip'] = request()->ip();
        if(\SYSTEM_ID == $data['user_id']){
            return \verify_err($data, '不能为系统用户充值');
        }
        return $this->stepRun($data, 'serverfund/currency/CurrencyAccount/prepaid', 'prepaid', 'prepaid');
    }
    # 冻结 a
    public function freeze(): array
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'currency'=>'0', 'token'=>' ', 'reason'=>' ']);
        return $this->stepRun($data, 'serveruser/user/User/infoByIds,serveruser/auth/App/find,serverfund/currency/CurrencyAccount/adminFreeze', '', 'freeze');
    }
    # 解冻 a
    public function unfreeze(): array
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'currency'=>'0', 'obj_id'=>'0', 'token'=>' ', 'remark'=>'']);
        return $this->stepRun($data, 'serveruser/auth/Token/hGetAll,serveruser/auth/App/find,serverfund/currency/CurrencyAccount/unfreeze', '', 'unfreeze');

    }
    // 获取列表
    public function list(): array
    {
        $data = $this->haveIssetReceiveData(['page'=>'1', 'list_rows'=>'', 'token'=>' ', 'keywords'=>'']);
        return $this->stepRun($data, 'serverfund/currency/CurrencyAccount/list', 'list', 'list');
    }
    // 某user_ids的用户资金列表
    public function listByUserIds(): array
    {
        $data = $this->haveIssetReceiveData(['user_ids'=>' ','token'=> ' ']);
        return $this->stepRun($data, 'serverfund/currency/CurrencyAccount/listByUserIds', 'listByUserIds', 'listByUserIds');
    }

}